<?php

/**
 * Usuario form base class.
 *
 * @method Usuario getObject() Returns the current form's model object
 *
 * @package    auip
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseUsuario3Form extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'email'                    => new sfWidgetFormInputText(),
      'nombre'                   => new sfWidgetFormInputText(),
      'apellidos'                => new sfWidgetFormInputText(),
      //'password'                 => new sfWidgetFormInputPassword(array(),array('size'=>'25')),
      //'password2'                 => new sfWidgetFormInputPassword(array(),array('size'=>'25')),
      //'id_perfil'                => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Perfiles'), 'add_empty' => true)),
      //'registro_activo'          => new sfWidgetFormInputText(),
      'identificacion_pasaporte' => new sfWidgetFormInputText(array(),array('size'=>'25')),
      'nacionalidad_id'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Pais'), 'order_by' => array('nombre','asc'), 'add_empty' => true)),
      'pais_residencia_id'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Pais_3'), 'order_by' => array('nombre','asc'), 'add_empty' => true)),
      'fecha_nacimiento'         => new sfWidgetFormInputText(),
      'lugar_nacimiento'         => new sfWidgetFormInputText(),
      'direccion'                => new sfWidgetFormInputText(),
      'telefono'                 => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'email'     				=> new sfValidatorEmail(array('required'=>true), array('required'=> "El email es obligatorio")),
      'nombre'                   => new sfValidatorString(),
      'apellidos'                => new sfValidatorString(),
      //'password'                 => new sfValidatorString(),
      //'password2'                 => new sfValidatorString(),
      //'id_perfil'                => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Perfiles'), 'required' => false)),
      //'registro_activo'          => new sfValidatorInteger(array('required' => false)),
      'identificacion_pasaporte' => new sfValidatorString(array('required' => false)),
      'nacionalidad_id'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Pais'), 'required' => false)),
      'pais_residencia_id'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Pais_3'), 'required' => false)),
      'fecha_nacimiento'         => new sfValidatorDate(array('required' => false)),
      'lugar_nacimiento'         => new sfValidatorString(array('required' => false)),
      'direccion'                => new sfValidatorString(array('required' => false)),
      'telefono'                 => new sfValidatorString(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('usuario[%s]');
/*
    $this->validatorSchema->setPostValidator(new sfValidatorAnd(array(
            new sfValidatorSchemaCompare('password2', sfValidatorSchemaCompare::EQUAL, 'password', array('throw_global_error' => true), array('invalid' => "Las dos contraseñas no coinciden")),
            new sfValidatorDoctrineUnique(array('model' => 'Usuario', 'column' => 'email', 'primary_key' => 'id', 'required' => true), array('invalid'=> "Este email ya está en uso"))
        )));

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
*/
    $decorator = new myWidgetFormSchemaFormatterCustom($this->getWidgetSchema());
  	$this->widgetSchema->addFormFormatter('custom', $decorator);
  	$this->widgetSchema->setFormFormatterName('custom');
    
    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Usuario';
  }

}//
